#include<stdio.h>
#include<string.h>
#include<time.h>
void gues_with_com(){
	char gus[3][10]={"scissor","stone","cloth"};
	printf("computer guess:%s\n",gus[1]);
	int man,comp;
	srand(time(NULL));
	while(1){
		comp=rand() %3;
		printf("input your guess:0-scissor,1-stone,2-cloth\n");
		int res=scanf("%d",&man);
		if(res !=1 || (man <0 || man >2)){
			printf("input error, please input 0,1,2\n");
			continue;
		}
		printf("your guess:%s,computer guess:%s\n",gus[man],gus[comp]);
		int result=(man-comp+4)%3-1;
		if(result==0)
			printf("you are the same\n");
		if (result>0)
			printf("you win\n");
		else
			printf("you lost\n");
	}
}
int hour = 23, minute = 59;
void print_time()
{
    printf("print time %d:%d\n", hour, minute);
}

void Test1() //page66: local variable assign and free
{
    int i;
    printf("%d\n", i);
    i = 66;
}

int Test2(int n)
{
	int res=0;
    if(n == 0)
        return 1;
    else
        res = n*Test2(n - 1);
    return res;
}

void test3(){
	int i,j;
	for(i=1;i<10;i++)
	{
		for(j=1;j<10;j++)
			printf("%d\t",i*j);
		printf("\n");
	}
	printf("----------------------up --------------------\n");
	int a,b;
	for(a=1;a<10;a++){
		for(b=1;b<=a;b++)
			printf("%d\t",a*b);
		printf("\n");
	}
	printf("-------------------------down-----------------\n");
	int c,d;
	for(c=1;c<10;c++){
		for(d=1;d<10-c+1;d++)
			printf("%d\t",c*d);
		printf("\n");
	}
}
void my_rand()
{
	int i,b;
	printf("get 10~20 rand num\n");
	for(i=10;i<=20;i++){
		b=rand()%11+10;
		printf("b=%d\n",b);
	}
}

int main(int argc, char ** argv)
{
    int hour = 20, minute = 30;
    print_time();
    printf("main time %d:%d\n", hour, minute);
    Test1();
    printf("helen\n");
    Test1();
    //run two times Test1() and insert a print, is not same
    Test1();
    Test1();
    int test2_r=Test2(6); //6!=6*5*4*3*2*1
	printf("result=%d\n",test2_r);
	test3(); //9.9 table
	my_rand();
	gues_with_com();
    return 0;
}
